package control;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.National;
public class DelNational extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public DelNational() {
        super();
    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		String n = request.getParameter("nid");
		String del = request.getParameter("delete");
		National national = new National();
		if (del.equals("yes")) {
			national.del(Integer.parseInt(n));
			request.setAttribute("m", "del-naok");
			request.setAttribute("r","vn");
			RequestDispatcher transferexist = getServletContext().getRequestDispatcher("/a/message.jsp");
			transferexist.forward(request, response);
		} else {
			RequestDispatcher transfer = getServletContext().getRequestDispatcher("/a/national.jsp");
			transfer.forward(request, response);
		}
	}

}
